﻿<script>
function thuchienxoa(){
	var f = document.ds_mau_tin_td;
	var ds_mt = "";
	if(f.chkxoa.length != undefined){  //trong tinh trang co 2 cai de xoa
		var len = f.chkxoa.length;
		for( var i = 0; i < len; i++){
			if( f.chkxoa[i].checked){
				if( ds_mt == ""){
					ds_mt = f.chkxoa[i].value;
				}else ds_mt = ds_mt+","+f.chkxoa[i].value;
			}
		}
	}else 
	if(f.chkxoa.checked){
				ds_mt = f.chkxoa.value;
			}
	if(ds_mt == ""){
		alert('Vui lòng chọn mẩu tin cần xóa...');
		return false;
	}
	if(confirm('Bạn chắc chắn muốn xóa không?')){
		document.frmDLxoa.ms_mt.value=ds_mt;
		document.frmDLxoa.submit();
	}
}

function tim(id){
	var ms = document.getElementById(id).value;
	var regex=/^([0-9]*)$/;
	if(ms == ""){
		document.getElementById('tb').innerHTML = "Vui lòng nhập mã số!";
		//document.getElementById('msg').style.color = 'red';
	}
	else if(!ms.match(regex)){
		document.getElementById('tb').innerHTML = "Mã số là một chữ số!";
		//document.getElementById('msg').style.color = 'red';
	}
	else{
		document.getElementById('tb').innerHTML = "";
		xmlHttp = taoXmlHttpOb();
		xmlHttp.onreadystatechange=function() 
				{ 
				if(xmlHttp.readyState==4) 
				  { 
					document.getElementById("dsmt_td").innerHTML = xmlHttp.responseText;
				  } 
				}
				xmlHttp.open("GET","dang_tin_td/ds_mau_tin_td_tim.php?ms="+ms,true);
			xmlHttp.send(null);
	}
}

function tin_hh(){
	xmlHttp = taoXmlHttpOb();
	xmlHttp.onreadystatechange=function() 
			{ 
			if(xmlHttp.readyState==4) 
			  { 
				document.getElementById("dsmt_td").innerHTML = xmlHttp.responseText;
			  } 
			}
			xmlHttp.open("GET","dang_tin_td/ds_mau_tin_td_hh.php",true);
			xmlHttp.send(null);
}
</script>
<?php
	$p = new pager3;
	
	$limit = 20;
	
	$start = $p->find_start($limit);
	
	$count = mysql_num_rows(mysql_query("SELECT * FROM mau_tin_td"));
	
	$pages = $p->find_pages($count, $limit);

	mysql_query("SET character_set_results=utf8"); //lấy dữ liệu tiếng việt từ csdl
	$sql="SELECT *, DATE_FORMAT(ngay_dang,'%d-%m-%Y %H:%i:%s') AS ngay 
		  FROM mau_tin_td a, linh_vuc_td b 
		  WHERE a.ms_linh_vuc = b.ms_linh_vuc 
		  ORDER BY ngay_dang DESC 
		  LIMIT ".$start.",".$limit;
	$rs=mysql_query($sql);
	$so_mau_tin = mysql_num_rows($rs);
?>
<form name="ds_mau_tin_td">
<div align="right">
<table cellspacing="10">
	<tr>
    	<td><div id="tb" style="color:#F00;"></div></td>
    	<td><b>Mã số: </b></td>
        <td><input type="text" id="ms_tim" name="ms_tim" size="8"/></td>
        <td><input type="button" name="" value=" Tìm " onclick="tim('ms_tim')" class="button" /></td>
        <td><input type="button" class="button" onclick="location.href='index.php?noidung=dsmt_td'" value=" Tất cả " /></td>
        <td><input type="button" name="" value=" Tin hết hạn " onclick="tin_hh()" class="button" /></td>
    </tr>
</table>
</div>
<br />
<table id="dsmt_td" border="0" cellspacing="0" cellpadding="2" class="table" width="100%">
  <tr>
    <td colspan="9"><h2><b>Danh sách mẩu tin tuyển dụng</b></h2></td>
  </tr>
  <tr>
    <td align="center" class="title_left">MÃ SỐ</td>
    <td align="center" class="title_row">NGƯỜI TẠO</td>
    <td align="center" class="title_row">NHÀ TUYỂN DỤNG</td>
    <td align="center" class="title_row">LĨNH VỰC TUYỂN DỤNG</td>
    <td align="center" class="title_row">NGÀY ĐĂNG</td>
	<td align="center" class="title_row">SỐ NGÀY TT</td>
    <td align="center" class="title_row">GIẤY PHÉP</td>
    <td align="center" class="title_row"><font color="#00FF00">Sửa</font></td>
    <td align="center" class="title_row"><font color="#FF0000">Xóa</font></td>
  </tr>
<?php
	while($rw=mysql_fetch_row($rs)){
?>
  <tr>
    <td class="stt"><?php echo $rw[0] ?>&nbsp;</td>
    <td class="data_row"><?php echo $rw[2] ?>&nbsp;</td>
    <td class="data_row"><?php echo $rw[3] ?>&nbsp;</td>
    <td class="data_row"><?php echo $rw[17] ?>&nbsp;</td>
    <td class="data_row"><?php echo $rw[18] ?>&nbsp;</td>
    <td class="data_row"><?php echo $rw[11] ?>&nbsp;</td>
    <?php
		if($rw[15]==1){
    		echo '<td class="data_row">Đã đăng</td>';
		}else {
    		echo '<td class="data_row"><a href="dang_tin_td/xl_cho_phep_dang_tin_td.php?mt_td='.$rw[0].'">Đăng</a></td>';
		}
	?>
    <td class="data_row"><a href="index.php?noidung=sua_td&&mt_td=<?php echo $rw[0];?>"><img src="images/edit.gif" border="0" /></a></td>
    <td class="data_row"><input type="checkbox" name="chkxoa" value="<?php echo $rw[0];?>"/></td>
  </tr>
<?php
	} 
?>
	<tr>
  		<td height="20" align="center" colspan="9"><b>Tổng số mẩu tin: <?php echo $count ?></b></td>
  	</tr>
</table>
<?php
	$page_list = $p->page_list($_GET['page'], $pages);
	echo "<div class='pagenavi'>".$page_list."</div>";
?>
<div align="center">
<input type="button" name="them" id="them" value=" Thêm mẩu tin " onclick="location.href='index.php?noidung=them_td'" class="button"/>&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" name="xoa" id="xoa" value=" Xóa " onClick="thuchienxoa()" class="button"/>
</div><br />
<div align="center"><a href="index.php?noidung=ql">Trở về trang quản lý</a></div>
</form>
<form name="frmDLxoa" action="dang_tin_td/xl_xoa_mau_tin_td.php" method="post">
<input type="hidden" name="ms_mt" value=""/>
</form>
